home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / MCI.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  142 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Windows MCI (Media Control Interface) encapsulation classes.
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_MCI_H)
  10. #define OWL_MCI_H
  11.  
  12. #if !defined(OWL_WINDOW_H)
  13. # include <owl/window.h>
  14. #endif
  15. #if !defined(_INC_MMSYSTEM)
  16. # include <mmsystem.h>
  17. #endif
  18.  
  19. #if defined(BI_NAMESPACE)
  20. namespace OWL {
  21. #endif
  22.  
  23. // Generic definitions/compiler options (eg. alignment) preceeding the 
  24. // definition of classes
  25. #include <services/preclass.h>
  26.  
  27. class _OWLCLASS TMci;
  28.  
  29. //
  30. // class TMciHiddenWindow
  31. // ~~~~~ ~~~~~~~~~~~~~~~~
  32. // A private TWindow derivative used by TMci to capture events.
  33. //
  34. class _OWLCLASS TMciHiddenWindow : public TWindow {
  35.   public:
  36.     TMciHiddenWindow(TMci&, TModule* = 0);
  37.  
  38.     TResult MciNotify(TParam1, TParam2);
  39.  
  40.   private:
  41.     TMci& Mci;
  42.  
  43.   DECLARE_RESPONSE_TABLE(TMciHiddenWindow);
  44. };
  45.  
  46. //
  47. // class TMci
  48. // ~~~~~ ~~~~
  49. // Wrapper for the MCI multimedia services.
  50. //
  51. class _OWLCLASS TMci {
  52.   public:
  53.     // Constructors and destructors
  54.     //
  55.     TMci();
  56.     virtual ~TMci();
  57.  
  58.     // Available commands on any MCI device
  59.     //
  60.     uint32  Open(MCI_OPEN_PARMS, uint32 command = 0);
  61.     uint32  Close();
  62.     uint32  Play(MCI_PLAY_PARMS, uint32 flags = 0);
  63.     uint32  Stop(uint32 flags = 0);
  64.     uint32  Pause(uint32 flags = 0);
  65.     uint32  Resume(uint32 flags = 0);
  66.     uint32  Seek(MCI_SEEK_PARMS, uint32 flags = 0);
  67.     uint32  Seek(uint32 to, uint32 flags = 0);
  68.     uint32  Load(const char far* fileName, uint32 flags = 0);
  69.  
  70.     // Virtual function to override in derived classes to know when
  71.     // an MCI event is finished.
  72.     //
  73.     virtual TResult MciNotify(TParam1, TParam2);
  74.  
  75.     // State information
  76.     //
  77.     bool    IsBusy() const;
  78.     void    SetBusy(bool);
  79.  
  80.     // General wrappers and properties
  81.     //
  82.     uint32  SendCommand(uint msg, uint32 command, uint32 param);
  83.     uint    GetDeviceId() const;
  84.     uint32  GetCallback() const;
  85.     static uint32 SendCommand(uint deviceId, uint msg, uint32 command, uint32 param);
  86.  
  87.   private:
  88.     void     SetBusyIfNeeded(uint32 command);
  89.  
  90.     uint     DeviceId;                    // Id for the MCI device
  91.     bool     WaitingForNotification;      // Flag for asynchronous busy
  92.     TWindow* Window;                      // Owner
  93. };
  94.  
  95. //
  96. // class TMciWaveAudio
  97. // ~~~~~ ~~~~~~~~~~~~~
  98. // Wrapper to play .WAV files.
  99. //
  100. class _OWLCLASS TMciWaveAudio : public TMci {
  101.   public:
  102.     TMciWaveAudio(const char far* elementName = 0, const char far* deviceName = 0,
  103.       uint16 id = 0);
  104.  
  105.     uint32 Play(uint32 flags = 0, uint32 from = 0, uint32 to = 0);
  106. };
  107.  
  108. // Generic definitions/compiler options (eg. alignment) following the 
  109. // definition of classes
  110. #include <services/posclass.h>
  111.  
  112. #if defined(BI_NAMESPACE)
  113. } // namespace OWL
  114. #endif
  115.  
  116. //----------------------------------------------------------------------------
  117. // Inline implementations
  118. //
  119.  
  120. //
  121. // Return the ID of the open MCI device.
  122. //
  123. inline uint TMci::GetDeviceId() const {
  124.   return DeviceId;
  125. }
  126.  
  127. //
  128. // Return true if the MCI is currently busy doing something.
  129. //
  130. inline bool TMci::IsBusy() const {
  131.   return WaitingForNotification;
  132. }
  133.  
  134. //
  135. // Sets the busy flag for the MCI device.
  136. //
  137. inline void TMci::SetBusy(bool b) {
  138.   WaitingForNotification = b;
  139. }
  140.  
  141. #endif  // OWL_MCI_H
  142.